package cn.anecansaitin.industrialization_expansion.common.event;

import cn.anecansaitin.industrialization_expansion.ExtensionLoader;
import cn.anecansaitin.industrialization_expansion.ModConstant;
import cn.anecansaitin.industrialization_expansion.common.CommonEventHooks;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import java.util.List;
//老的注册方式，以转移到ItemRegister中，暂时不注册时间
//@Mod.EventBusSubscriber(modid = ModConstant.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ItemRegisterEvent {
    @SubscribeEvent
    public static void register(RegistryEvent.Register<Item> event) {
        CommonEventHooks.fireToolRegisterEvent();
        List<Item> tools = ExtensionLoader.TOOLS;

        for (int i = 0, toolsSize = tools.size(); i < toolsSize; i++) {
            Item tool = tools.get(i);
            event.getRegistry().register(tool.setRegistryName(ModConstant.MOD_ID, ExtensionLoader.TOOL_IDS.get(i)));
        }

        CommonEventHooks.fireModuleRegisterEvent();
        List<Item> modules = ExtensionLoader.MODULES;

        for (int i = 0, modulesSize = modules.size(); i < modulesSize; i++) {
            Item module = modules.get(i);
            event.getRegistry().register(module.setRegistryName(ModConstant.MOD_ID, ExtensionLoader.MODULE_IDS.get(i)));
        }
    }
}
